# coding: utf8


import numpy as np
import pandas as pd
import random

class DataSet:

    # default dtype, index
    sr1 = pd.Series(range(5))
    # default index, dtype=np.int8
    sr2 = pd.Series(range(5), dtype=np.int8)
    # default dtype, index set to str list
    sr3 = pd.Series(range(5), index=[str(i) for i in range(5)])
    # duplicate index value
    sr4 = pd.Series(range(5), index=[1, 2, 1, 2, 3])
    # multi-index
    sr5 = pd.Series(range(5), index=[[0,  0,  1,  1,  1],  ['a', 'b', 'a', 'b', 'c']])
    sr6 = pd.Series([100, 90, 95, 80, 89],
                    index=pd.MultiIndex.from_tuples(
                        [('李明', '期中'), ('李明', '期末'),
                         ('张乐', '期中'), ('张乐', '期末'),
                         ('何婷', '期中')])
                    )
    sr7 = pd.Series([random.randint(60, 100) for _ in range(12)],
                    index=pd.MultiIndex.from_product(
                        [['李明', '张乐', '何婷'],
                         ['初考', '作业', '例考', '终考']]),
                    dtype=np.uint8
                    )

    sr = [sr1, sr2, sr3, sr4, sr5, sr6, sr7]

    # 使用临时数据创建DataFrame
    df1 = pd.DataFrame(data=[[(x+1)**y for y in range(3)] for x in range(3)],
                       columns=list('ABC'),
                       index=pd.date_range('2010.1.1', periods=3),
                       dtype=np.int8)
    # 拷贝df1,不共享
    df2 = pd.DataFrame(data=df1,
                       copy=True)
    df2.index = range(3)
    # 与df1共享数据
    df3 = pd.DataFrame(data=df2,
                       copy=False)
    # MultiIndex
    df4 = pd.DataFrame(
        {'语文': [random.randint(60, 100) for _ in range(12)],
         '数学': [random.randint(60, 100) for _ in range(12)]},
        index=pd.MultiIndex.from_product(
            [['李明', '张乐', '何婷'], ['初考', '作业', '例考', '终考']]),
        dtype=np.uint8)

    df5 = pd.DataFrame(np.arange(60, 84).reshape(12, 2),
                       columns=['math', 'science'],
                       index=pd.MultiIndex.from_product(
                            [[1, 2, 3], ['t1', 't2', 't3', 't4']]),
                       dtype=np.uint8)

    data = [[-1.037109, 0.784668, -0.408447],
            [ 0.874512, 1.262695, -0.703613],
            [-1.017578, 0.775391,  0.502441]]

    df6 = pd.DataFrame(data=np.array(data),
                       index=pd.date_range('2010.1.1', '2010.1.3'),
                       columns=['A', 'B', 'C'])

    df = [df1, df2, df3, df4, df5, df6]
